#include <stdio.h>
#include <stdlib.h>
typedef struct queue
{
    int data[10];
    int front;
    int rear;
}queue;
queue *init(){
    queue *q=malloc(sizeof(queue));
    q->front=0;
    q->rear=0;
    return q;
}
int isempt(queue q){
    int flage=0;
    if(q.front==q.rear){
        flage=1;
    }
    return flage;
}
int isfull(queue q){
    int flage=0;
    if((q.front+1)%10==q.rear){
        flage==1;
    }
    return flage;
}
void push(queue *q,int data){
    if(isfull(*q)==1){
        printf("满了\n");
    }
    else{
        q->data[q->front]=data;
        q->front=(q->front+1)%10;
    }
}
int pop(queue *q){
    int back;
    if(isempt(*q)==1){
        back=0;
    }
    else{
        back=q->data[q->rear];
        q->rear=(q->rear+1)%10;
    }
    return back;
}
void main(){
    int n;
    queue *q=init();
    while(1==1)
    {
        printf("输入一个数给这个队列");
        scanf("%d",&n);
        if(n==0) break;
        push(q,n);
    }
    while (isempt(*q)==0)
    {
       printf("%d\n",pop(q));
    }   
}